package com.example.pointerdemo

import android.app.Activity
import android.app.Application
import android.os.Bundle
import android.util.Log

/**
 * @Author xiao
 * @Date 2021/6/16
 * @Description
 */
class App : Application() {

    override fun onCreate() {
        super.onCreate()
        registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
            override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
                Log.d(activity::class.java.name, "onActivityCreated")
            }

            override fun onActivityStarted(activity: Activity) {
                Log.d(activity::class.java.name, "onActivityStarted")
            }

            override fun onActivityResumed(activity: Activity) {
                Log.d(activity::class.java.name, "onActivityResumed")
                val rootView = activity.window.decorView.rootView
                HookClickHelper.hook(rootView)
            }

            override fun onActivityPaused(activity: Activity) {
                Log.d(activity::class.java.name, "onActivityPaused")
            }

            override fun onActivityStopped(activity: Activity) {
                Log.d(activity::class.java.name, "onActivityStopped")
            }

            override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
                Log.d(activity::class.java.name, "onActivitySaveInstanceState")
            }

            override fun onActivityDestroyed(activity: Activity) {
                Log.d(activity::class.java.name, "onActivityDestroyed")
            }
        })
    }
}